import {
	GetRequest,
	PostFormRequest,
	PostJsonRequest,
	uploadImageRequest
} from '@/api/request.js'

const baseUrl = 'http://47.97.22.92:8013';
//const baseUrl = 'http://127.0.0.1:8013';

export function login(code) {
	return PostJsonRequest(baseUrl + '/v1/api/public/wxa_login', {
		code: code
	})

}

export function updateUserInfo(userInfo) {
	return PostJsonRequest(baseUrl + '/v1/api/user/info/update', {
		file_url: userInfo.avatarUrl,
		nickname: userInfo.nickname,
		gender_code: userInfo.genderCode,
		birthday: userInfo.birthday,
		user_type: userInfo.userType
	})
}

export function getUserInfo() {
	return GetRequest(baseUrl + '/v1/api/user/info')
}

//baby
export function babyClockTaskList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/baby/clock_task/list', {
		task_type: listReq.type,
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}

export function babyClockTaskItem(taskSID) {
	return GetRequest(baseUrl + '/v1/api/baby/clock_task/item', {
		task_sid: taskSID
	})
}

export function babyRelationAdd(code) {
	return PostJsonRequest(baseUrl + '/v1/api/baby/relation/add', {
		code: code
	})
}

export function babyFinishTaskAdd(taskSID) {
	return PostJsonRequest(baseUrl + '/v1/api/baby/finish/add', {
		task_sid: taskSID
	})
}

export function babyExchangeAdd(shopUUID) {
	return GetRequest(baseUrl + '/v1/api/baby/shop/exchange', {
		shop_uuid: shopUUID
	})
}


//patriarch
export function patriarchClockTaskAdd(addReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/clock_task/add', {
		task_name: addReq.taskName,
		task_content: addReq.taskContent,
		task_score: addReq.taskScore,
		start_time: addReq.startTime,
		task_type: addReq.taskType
	})
}
export function patriarchClockTaskDel(taskSID) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/clock_task/del', {
		task_sid: taskSID
	})
}
export function patriarchClockTaskUpdate(updateReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/clock_task/update', {
		task_name: updateReq.taskName,
		task_content: updateReq.taskContent,
		task_score: updateReq.taskScore,
		start_time: updateReq.startTime,
		task_sid: updateReq.taskSid,
		task_type: updateReq.taskType
	})
}
export function patriarchClockTaskList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/clock_task/list', {
		task_type: listReq.type,
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}
export function patriarchClockTaskItem(taskSID) {
	return GetRequest(baseUrl + '/v1/api/patriarch/clock_task/item', {
		task_sid: taskSID
	})
}

export function patriarchShopAdd(addReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/shop/add', {
		shop_name: addReq.shop_name,
		shop_url: addReq.shop_url,
		shop_content: addReq.shop_content,
		shop_score: addReq.shop_score,
		amount: addReq.amount
	})
}

export function patriarchShopUpdate(updateReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/shop/update', {
		shop_name: updateReq.shop_name,
		shop_url: updateReq.shop_url,
		shop_content: updateReq.shop_content,
		shop_score: updateReq.shop_score,
		amount: updateReq.amount,
		shop_uuid: updateReq.shop_uuid
	})
}

export function patriarchShopDel(shopUUID) {
	return GetRequest(baseUrl + '/v1/api/patriarch/shop/del', {
		shop_uuid: shopUUID
	})
}


export function patriarchShopItem(shopUUID) {
	return GetRequest(baseUrl + '/v1/api/patriarch/shop/item', {
		shop_uuid: shopUUID
	})
}

export function patriarchScoreAdd(addReq) {
	return PostJsonRequest(baseUrl + '/v1/api/patriarch/score/add', {
		user_sid: addReq.user_sid,
		score: addReq.score,
		change_type: addReq.change_type,
		change_name: addReq.change_name,
	})
}

//public
export function publicShopList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/public/shop/list', {
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}

export function publicUserScore() {
	return GetRequest(baseUrl + '/v1/api/user/score')
}


export function publicScoreList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/public/score/list', {
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}


export function publicFinishTaskList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/public/finish/list', {
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}

export function publicExchangeList(listReq) {
	return PostJsonRequest(baseUrl + '/v1/api/public/exchange/list', {
		page_info: {
			page: listReq.pageInfo.page,
			size: listReq.pageInfo.size
		}
	})
}

export function publicRelationList() {
	return GetRequest(baseUrl + '/v1/api/public/relation/list')
}

export function publicAffiche() {
	return GetRequest(baseUrl + '/v1/api/public/affiche')
}

export function publicAfficheList() {
	return GetRequest(baseUrl + '/v1/api/public/affiche/list')
}

export function publicUpload(file) {
	return uploadImageRequest(baseUrl + '/v1/api/public/upload', {
		image: file
	})
}